package com.xbb.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xbb.entity.ReadRoom;
import com.xbb.entity.dto.ReadRoomDto;
import com.xbb.service.ReadRoomService;
import com.xbb.util.Result;

@RestController
public class ReadRoomController {

	@Autowired
	ReadRoomService readRoomService;
	
	@RequestMapping("/getReadList")
	public Object getReadList(ReadRoomDto readRoomDto,ModelMap map) {
		List<ReadRoomDto> list = readRoomService.getReads(readRoomDto);
		readRoomDto.setLimit(null);
		readRoomDto.setPage(null);
		List<ReadRoomDto> list2 = readRoomService.getReads(readRoomDto);
		return new Result(0,"",list2.size(),list);
	}
	
	
	@RequestMapping("/addRead")
	public Object addRead(ReadRoom readRoom) {
		if(readRoomService.addRead(readRoom)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	@RequestMapping("/updateRead")
	public Object updateRead(ReadRoom readRoom) {
		if(readRoomService.updateRead(readRoom)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	@RequestMapping("/delRead")
	public Object delRead(int rid) {
		if(readRoomService.delRead(rid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
	
	
}











